package com.tengju.bff.interfaces.covercharge.constant;


import java.util.Objects;

public enum SignOnErrorCode implements IErrorEnum {
    /*//通用错误码
    SYSTEM_UNKNOWN_ERROR(249998, "系统未知错误"),
    SERVICE_PAUSE(249999, "系统暂停"),
    SYSTEM_ERROR(240001, "系统产生的错误"),
    SYSTEM_TIMEOUT(240002,"系统超时"),
    SYSTEM_BUSY(240003, "系统忙"),
    CONFIG_ERROR(240004, "配置异常"),
    PERFORM_ERROR(240005, "执行异常"),
    PARAM_ERROR(240006, "参数传递异常"),
    NOT_EXIST_ERROR(240007, "不存在异常"),
    EXIST_ERROR(240008, "已存在异常"),
    SYSTEM_BAN_ERROR(240009, "系统禁止异常"),
    NOT_SUPPORT(240010, "不支持"),
    OVERDUE_ERROR(240011, "过期异常"),
    SIGN_ERROR(240012, "验证签名错误异常"),
    LOCK_ERROR(240013, "加锁异常"),
    UNLOCK_ERROR(240014, "解锁异常"),
    SEND_SMS_ERROR(240015, "发送SMS信息异常"),
    CODE_ERROR(240016, "验证码错误"),
    URL_ERROR(240017, "无效的URL"),

    //与开发者相关
    DEVELOPER_NOT_EXIST(241107, "开发者不存在"),
    DEVELOPER_EXIST(241108, "开发者已经存在"),
    DEVELOPER_DISABLE(241109, "开发者被禁用"),
    DEVELOPER_SIGN_ERROR(241112, "开发者签名错误"),
    DEVELOPER_NO_CERTIFICATION_KEY(241115, "开发者没有认证的key"),
    DEVELOPER_NO_RSA_KEY(241116, "开发者没有RSA key"),
    DEVELOPER_NO_CONFIG(241117, "开发者没有相应的配置项"),

    //与用户相关
    NO_USER_TYPE(241206, "缺少用户类型"),
    USER_NOT_EXIST(241207, "用户不存在"),
    USER_EXIST(241208, "用户已经存在"),
    USER_IS_BAN(241209, "用户被禁止"),
    USER_SIGN_IMG_NOT_EXIST(241217, "用户签名图片不存在"),
    USER_SIGN_IMG_EXIST(241218, "用户签名已经存在"),
    USER_CERTIFICATION_NOT_EXIST(241227, "用于认证的信息不存在"),
    USER_REGISTER_ERROR(241228, "用户注册失败"),
    USER_SAVE_ERROR(241229, "保存认证信息失败"),
    UPLOAD_SIGN_IMG_ERROR(241230, "上传签名图片失败"),
    THE_THIRD_ERROR(241601, "第三方供应商返回的具体错误信息"),*/

    //与证书相关
    CERTIFICATION_CHECK_ERROR(240006, "校验不通过,请检查输入的信息是否正确"),
    USER_ACCOUNT_NOT_EXIST(241207, "该account不存在，可能还未调用注册接口或注册失败"),
    APPLY_CERTIFICATE_TIMEOUT(241303, "申请证书超时"),
    CERTIFICATE_NOT_EXIST(241307, "证书不存在"),
    CERTIFICATE_EXIST(241308, "证书已经存在"),
    CERTIFICATE_IS_DISABLE(241309, "证书被禁用"),
    CERTIFICATE_ERROR(241310, "证书不匹配"),
    APPLY_CERTIFICATE_ERROR(241317, "证书申请失败"),
    AGAIN_APPLY_CERTIFICATE(241321, "请重新申请证书"),

    /*//与合同相关
    CONTRACT_NOT_EXIST(241407, "合同不存在"),
    NOT_CONTRACT_USER(241410, "不是合同的拥有者"),
    CONTRACT_NO_END(241411, "合同未结束"),
    CONTRACT_SIGNING_ERROR(241412, "合同签署错误"),
    CONTRACT_NOT_REFUSED(241413, "合同不能被拒绝"),
    CONTRACT_NOT_ENDED(241414, "合同不能结束"),
    CONTRACT_NOT_DOING(241415, "合同不能被操作"),
    CONTRACT_END_ERROR(241416, "合同结束错误"),
    CONTRACT_UPDATE_ERROR(241417, "更新合同状态错误"),
    CONTRACT_CREATED_ERROR(241418, "创建合同失败"),
    CONTRACT_ADD_USER_ERROR(241419, "添加签署人失败"),
    CONTRACT_SIGN_ERROR(241420, "合同签署失败"),
    CONTRACT_NO_USER(241421, "合同没有签署人"),
    CONTRACT_MANUAL_ERROR(241422, "手动签错误"),
    CONTRACT_END_NOT_DON_ERROR(241423, "合同已结束不能被操作"),
    CONTRACT_SIGNED_OR_CANCEL_ERROR(241424, "签署者已签署或合同已被取消"),
    MICRO_SERVICE_ERROR(241501, "微服务调用异常"),

    //签署有关错误码
    SIGN_PARAM_ERROR(240006, "签署参数错误"),
    SIGN_CONTRACT_NOT_EXIST(240007, "合同不存在"),
    SIGN_USER_NOT_EXIST(241207, "用户不存在"),
    NOT_SIGNER(241421, "不是签署者"),*/
    END_CODE_ERROR(240016, "60秒内只允许一台手机只允许发送一次验证码"),
    SIGN_CODE_ERROR(240020, "验证码过期或不存在");

    private int code;
    private String msg;

    SignOnErrorCode(int code, String msg) {
        this.setCode(code);
        this.setMsg(msg);
    }

    @Override
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    public static SignOnErrorCode getInstance(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (SignOnErrorCode sign : SignOnErrorCode.values()) {
            if (code.equals(sign.code)) {
                return sign;
            }
        }
        return null;
    }
}
